//        https://ac.nowcoder.com/acm/problem/213484





#include<iostream>
using namespace std;

typedef long long LL;
const int N = 1e5 + 10;
int n;
int a[N];
LL dp[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    dp[0] = dp[1] = 0;
    dp[2] = a[1];
    for (int i = 3; i < n; i++)
        dp[i] = max(dp[i - 1], dp[i - 3] + a[i - 1]);

    cout << dp[n - 1] << endl;
    return 0;
}
